// $Id: ObjectifyDAO.java 65 2011-01-18 11:47:30Z E106005 $
package it.reichel.dao;

import com.google.appengine.api.datastore.EntityNotFoundException;
import com.googlecode.objectify.Key;

import java.util.List;
import java.util.Map;

public interface ObjectifyDAO<T> {

    /**
     *
     * @param entity
     * @return
     */
    Key<T> put(T entity);

    /**
     *
     * @param entities
     * @return
     */
    Map<Key<T>, T> putAll(Iterable<T> entities);

    /**
     *
     * @param entity
     */
    void delete(T entity);

    /**
     *
     * @param entityKey
     */
    void deleteKey(Key<T> entityKey);

    /**
     *
     * @param entities
     */
    void deleteAll(Iterable<T> entities);

    /**
     *
     * @param keys
     */
    void deleteKeys(Iterable<Key<T>> keys);

    /**
     *
     * @param id
     * @return
     * @throws EntityNotFoundException
     */
    T get(Long id) throws EntityNotFoundException;

    /**
     *
     * @param key
     * @return
     * @throws EntityNotFoundException
     */
    T get(Key<T> key) throws EntityNotFoundException;

    /**
     *
     * @param propName
     * @param propValue
     * @return
     */
    T getByProperty(String propName, Object propValue);

    /**
     *
     * @param propName
     * @param propValue
     * @return
     */
    List<T> listByProperty(String propName, Object propValue);

    /**
     *
     * @param propName
     * @param propValue
     * @return
     */
    List<Key<T>> listKeysByProperty(String propName, Object propValue);

    /**
     *
     * @param exampleObj
     * @return
     */
    T getByExample(T exampleObj);

    /**
     *
     * @param exampleObj
     * @return
     */
    List<T> listByExample(T exampleObj);
}
